﻿using System;
using System.Text;

namespace XBee.Test.Communications
{
    public class TestData : CommunicationData
    {
        #region Members
        private bool booldata=false;
        #endregion

        #region Properties
        public bool BoolData
        {
            get { return booldata; }
            set { booldata = value; }
        }
        #endregion

        #region Overrided Methods
        public override string ToString()
        {
            string res = string.Empty;
            res += TestData.sentencedelimiter;
            res += booldata ? "ON" : "OFF";
            res += TestData.sentencedelimiter;
            return res;
        }
        #endregion

        #region Static Methods
        public new static TestData TryParse(string sentence)
        {
            TestData res = new TestData();

            try
            {
                sentence = sentence.Trim();
                sentence=RemoveDelimiters(sentence);
                //res.BoolData = 
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print("Error en el procesamiento de datos de entrada" + ex.Message + "\r\n");
            }
            return res;
        }

        public new static bool IsSecuenceComplete(string tempData)
        {
            bool res = false;
            string sentence = tempData;

            res = sentence.Substring(0, TestData.sentencedelimiter.Length) == TestData.sentencedelimiter &&
                  sentence.Substring(sentence.Length - TestData.sentencedelimiter.Length, TestData.sentencedelimiter.Length) == TestData.sentencedelimiter;
            return res;
        } 
        #endregion
    }
}
